﻿using Easy.Cloud.Communication.Sms.Core.Enums;
using System;
using System.Collections.Generic;
using System.Text;

namespace Easy.Cloud.Communication.Sms.Core
{
    public class SendRequest 
    {
        private const string DefaultOption = "Default";
        public SendRequest( string phoneNumbers, string templateParam, string signName, string template)
        {
            SetPhoneNumbers(phoneNumbers);
            SetTemplateParam(templateParam);
            SetSignName(signName);
            SetTemplate(template);
        }

        public SendRequest(string phoneNumbers, string templateParam) : this(phoneNumbers, templateParam, DefaultOption, DefaultOption)
        {
        }
        /// <summary>
        /// 手机号 
        /// </summary>
        public string PhoneNumbers { get; private set; }
        /// <summary>
        /// 模板参数
        /// </summary>
        public string TemplateParam { get; private set; }
        /// <summary>
        /// 签名
        /// </summary>
        public string SignName { get; private set; }
        /// <summary>
        /// 模板
        /// </summary>
        public string Template { get; private set; }

        private void SetPhoneNumbers(string phoneNumber)
        {
            if (string.IsNullOrWhiteSpace(phoneNumber))
            {
                throw new SmsCoreException($"{nameof(phoneNumber)} Is Null Or WhiteSpace ");
            }
            PhoneNumbers = phoneNumber;
        }

        private void SetTemplateParam(string templateParam)
        {
            if (string.IsNullOrWhiteSpace(templateParam))
            {
                throw new SmsCoreException($"{nameof(templateParam)} Is Null Or WhiteSpace ");
            }
            TemplateParam = templateParam;
        }

        private void SetSignName(string signName)
        {
            if (string.IsNullOrWhiteSpace(signName))
            {
                throw new SmsCoreException($"{nameof(signName)} Is Null Or WhiteSpace ");
            }
            SignName = signName;
        }


        private void SetTemplate(string template)
        {
            if (string.IsNullOrWhiteSpace(template))
            {
                throw new SmsCoreException($"{nameof(template)} Is Null Or WhiteSpace ");
            }
            Template = template;
        }
    }
}
